// StringValue.cpp: implementation of the StringValue class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "StringValue.h"
#include "geassign.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

namespace StringValue
{

AcGeVector3d TextToGeVector3d( const char* tval ) throw ( TextException )
{
	CString val( tval );
	val.TrimLeft();
	val.TrimRight();
	if ( val.GetAt( 0 ) != _T( '(' ) || val.GetAt( val.GetLength() - 1 ) != _T( ')' ) )
		throw TextException();
	val = val.Mid( 1, val.GetLength() - 2 );
	AcGeVector3d v;
	int iPos = -1;
	iPos = val.Find( _T( ',' ), 0 );
	if ( iPos == -1 ) throw TextException();
	v.x = atof( val.Mid( 0, iPos ) );
	int iPos2 = val.Find( _T( ',' ), iPos + 1 );
	if ( iPos2 == -1 ) throw TextException();
	v.y = atof( val.Mid( iPos + 1, iPos2 - iPos - 1 ) );
	v.z = atof( val.Mid( iPos2 + 1 ) );
	return v;
}

AcGePoint3d TextToGePoint3d( const char* tval ) throw ( TextException )
{
	return asPnt3d( asDblArray( TextToGeVector3d( tval ) ) );
}

}
